#define _CRT_SECURE_NO_WARNINGS 1

/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     struct TreeNode *left;
 *     struct TreeNode *right;
 * };
 */
void swap(struct TreeNode** a, struct TreeNode** b)
{
    struct TreeNode* tmp = *a;
    *a = *b;
    *b = tmp;
}

struct TreeNode* invertTree(struct TreeNode* root) {
    if (root == NULL)
    {
        return NULL;
    }
    swap(&root->left, &root->right);
    invertTree(root->left);
    invertTree(root->right);
    return root;
}